import Child from "./Child"
import {useState,useCallback} from 'react'
export default ()=>{
    const [count,setCount]=useState(0)
    const [cnum,setCnum]=useState(10)
    console.log('-----父亲的render---------');
    const sayHello=(arg)=>{
        console.log('arg',arg);
    }   
    //useCallback的第一参数是你要缓存的函数，第2个参数如果是空数组，则记住第一次渲染的
    const sayHelloCallback=useCallback(sayHello,[count])
    return(<>
        <div>{count}</div>
        <button onClick={()=>setCount(count+1)}>+</button>
        <button onClick={()=>setCnum(cnum+1)}>++</button>
        <Child num={cnum} sayHello={sayHelloCallback}></Child>
    </>)
}